package com.chixing.Homework;

public class CreditAccount extends Account{
    //最高透支额度
    private double maxOverdraw;
    //信用度
    private double credit;



    public CreditAccount(long no, String name, long tel, long pwd, String email, double bal, int type) {
        super(no, name, tel, pwd, email, bal, type);
    }


    //取款  最高透支额度


    public  void draw(double drawMoney) {
        if((super.getAccBalance()+maxOverdraw) >= drawMoney && super.getAccBalance() >= drawMoney){
            double sum= super.getAccBalance() - drawMoney;
            System.out.println("取款成功!，余额为：" + sum + "   透支金额为：" + drawMoney);
        }else if((super.getAccBalance()+maxOverdraw) >= drawMoney && super.getAccBalance() < drawMoney){
            double sum = super.getAccBalance() + maxOverdraw - drawMoney;
            System.out.println("取款成功!，余额为：" + sum + "   透支金额为：" + drawMoney);
        }else{
            System.out.println("余额不足，取款失败!");
        }
    }

    public double getMaxOverdraw() {
        return maxOverdraw;
    }

    public void setMaxOverdraw(double maxOverdraw) {
        this.maxOverdraw = maxOverdraw;
    }

    public double getCredit() {
        return credit;
    }

    public void setCredit(double credit) {
        this.credit = credit;
    }
}
